﻿using System;
using System.Data;
using System.Collections.Generic;
using ZHDJ.MobileInterface.Common;

namespace ZHDJ.MobileInterface
{
    public partial class GetLawyerDetail : AbstractBasePage
    {
        protected override OutParam BusinessProcess<InParam, OutParam>(InParam inParam)
        {
            // 业务逻辑返回的响应对象  
            LawyerDetailOutParam result = new LawyerDetailOutParam();
            LawyerDetailInParam param = new LawyerDetailInParam();
            string logMsg = "";
            bool isFlag = true;

            try
            {
                param = inParam as LawyerDetailInParam;
                if (string.IsNullOrEmpty(param.LawyerID))
                {
                    result.code = "0";
                    result.desc = "律师ID不能为空";

                    isFlag = false;
                }

                DataSet ds = LawCs.Lawyer(param.LawyerID);
                if (ds==null||ds.Tables[0].Rows.Count < 1)
                {
                    result.code = "0";
                    result.desc = "律师ID不存在，请确认。";

                    isFlag = false;
                }
                if (isFlag)
                {
                    result.data.LawyerName = ds.Tables[0].Rows[0]["UserName"].ToString();
                    result.data.DianZan = ds.Tables[0].Rows[0]["DianZan"].ToString();
                    var day = (DateTime.Now - Convert.ToDateTime(ds.Tables[0].Rows[0]["JobTime"])).Days;
                    result.data.JobTime = Convert.ToString(day / 356 + (day % 356 > 200 ? 1 : 0));
                    result.data.RegistrationNum = ds.Tables[0].Rows[0]["RegistrationNum"].ToString();
                    result.data.Talents = ds.Tables[0].Rows[0]["Talents"].ToString();
                    result.data.ScoreReplyspeed = ds.Tables[0].Rows[0]["ScoreReplyspeed"].ToString();
                    result.data.ScoreBusinessLevel = ds.Tables[0].Rows[0]["ScoreBusinessLevel"].ToString();
                    result.data.WorkingAttitude = ds.Tables[0].Rows[0]["WorkingAttitude"].ToString();
                    result.data.Phone = ds.Tables[0].Rows[0]["Phone"].ToString();
                    result.data.WorkTime = ds.Tables[0].Rows[0]["WorkTime"].ToString();                    
                    result.data.LawFirmName = ds.Tables[0].Rows[0]["LawFirmName"].ToString();
                    result.data.Profiles = ds.Tables[0].Rows[0]["Profiles"].ToString();                    

                    result.data.MobileNo = ds.Tables[0].Rows[0]["MobileNoEx"].ToString();
                }

                logMsg = result.desc;
            }
            catch (Exception ex)
            {
                result.code = "0";
                result.desc = "操作异常，多次出现请联系管理员";
                logMsg = ex.Message + ":" + ex.StackTrace;
            }

            CommonUtils.InsertMobileInterfaceLog(SystemCode + "-GetLawyerDetail", SerializeHelper.JsonSerializer<LawyerDetailInParam>(param), logMsg);
            return result as OutParam;
        }

        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (string.Compare(Request.QueryString["Safe"], "False", true) == 0)
                ProcessRequest<LawyerDetailInParam, LawyerDetailOutParam>();
            else
                SafeProcessRequest<LawyerDetailInParam, LawyerDetailOutParam>();
        }
    }

    #region 请求参数
    public class LawyerDetailInParam
    {
        /// <summary>
        /// ID
        /// </summary>
        public string LawyerID
        { get; set; }
    }
    #endregion

    #region 结果参数
    public class LawyerDetailOutParam
    {
        public LawyerDetailOutParam()
        {
            code = "1";
            desc = "操作成功";
            data = new LawyerDetailData();
        }

        /// <summary>
        /// 返回结果 具体见接口返回对照码 1	成功 0	失败 2	请求非法 加密结果和传入的MD5字符串进行比较，如果相同则执行接口操作，否则返回1001错误响应码
        /// </summary>
        public string code
        { get; set; }

        /// <summary>
        /// 结果描述 成功和失败都需要
        /// </summary>
        public string desc
        { get; set; }

        /// <summary>
        /// 律师详细内容
        /// </summary>
        public LawyerDetailData data
        { get; set; }
    }

    /// <summary>
    /// 律师详细内容
    /// </summary>
    public class LawyerDetailData
    {
        /// <summary>
        ///		 
        /// </summary>
        public string LawyerName
        { get; set; }

        /// <summary>
        /// 爱心积分
        /// </summary>
        //public string ScoreLove
        //{ get; set; }

        /// <summary>
        /// 点赞
        /// </summary>
        public string DianZan
        { get; set; }

        /// <summary>
        /// 执业时间
        /// </summary>
        public string JobTime
        { get; set; }

        /// <summary>
        /// 执业证号
        /// </summary>
        public string RegistrationNum
        { get; set; }

        /// <summary>
        /// 事务所
        /// </summary>
        public string LawFirmName
        { get; set; }

        /// <summary>
        /// 擅长
        /// </summary>
        public string Talents
        { get; set; }

        /// <summary>
        /// 回复速度
        /// </summary>
        public string ScoreReplyspeed
        { get; set; }

        /// <summary>
        /// 业务水平
        /// </summary>
        public string ScoreBusinessLevel
        { get; set; }

        /// <summary>
        /// 律师态度
        /// </summary>
        public string WorkingAttitude
        { get; set; }

        /// <summary>
        /// 律所咨询电话
        /// </summary>
        public string Phone
        { get; set; }

        /// <summary>
        /// 服务时间
        /// </summary>
        public string WorkTime
        { get; set; }

        /// <summary>
        /// 联系电话
        /// </summary>
        public string MobileNo
        { get; set; }

        /// <summary>
        /// 律师简介
        /// </summary>
        public string Profiles
        { get; set; }
    }
    #endregion
}